# ---------------------------------------------------------------------------
### <Script>
### <Author>
### Chad Miller 
### </Author>
### <Description>
### Generates an RSS File for a Powershell object
### </Description>
### <Usage>
### Get-Service | New-RSS -feedTitle Get-Service -feedDescription Get-Service -itemTitle DisplayName -items Status,Name,DisplayName
### </Usage>
### </Script>
# ---------------------------------------------------------------------------

param($feedTitle,$feedDescription,$feedLink,$itemTitle="Name",$items="*")

Begin {
$rss = @"
<title>$feedTitle</title>
<description>$feedDescription</description>
<link>$feedLink</link>
<language>en-us</language>
<pubDate>$($(get-date).ToString("R"))</pubDate>
<generator>PoshRSS</generator>
"@
}
Process {

$itemDesc = "<table>"
    foreach ($item in $_ | Get-Member -Type *Property $items)
    {
        $name = $item.Name
        if ($name -eq $itemTitle)
        { $title = $($_.$name) }
        $itemDesc += "<tr><td>$name</td><td>$($_.$name)</td></tr>`n"
    }
$itemDesc += "</table>"

$rss += @"
<item>
<title>$title</title>
<description><![CDATA[$itemDesc]]></description>
</item>
"@

}
End {
$rss
}
